<?php

    header('Content-Type: text/javascript');
    header('Cache-Control: no-cache');
    header('Pragma: no-cache');

    require_once 'mysql.php';

    $link = connect();
    mysql_select_db("c2cv2",$link);


    $query = "select datebint, sum(1) as numvotes from vote WHERE SESSION = ". $_GET['session'] . " AND `where` = '" . $_GET['chamber'] . "' group by datebint order by datebint asc";
    //echo $query;

    $rs = mysql_query($query) or die("MySQL error: " . mysql_error());


    $json =  '[';

    $session = $_GET['session'];
    $chamber = $_GET['chamber'];


    while($o = mysql_fetch_array($rs,MYSQL_ASSOC)) {
    //	echo "<pre>" . print_r($o) . "</pre>";
        $numvotes = $o['numvotes'];
        $datebint = $o['datebint'];

        $json .= '{';

        $json .= "\"chamber\":\"$chamber\",";
        $json .= "\"session\":\"$session\",";
        $json .= "\"numVotes\":\"$numvotes\",";
        $json .= "\"date\":\"$datebint\"";

        $json .= '},';

    }
    $json = substr($json,0,strlen($json)-1);

    disconnect($link);

    $json .= ']';

    echo $json;

?>